package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return
     */
   Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     *根据主键id查询菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    /**
     * 根据id批量删除菜品
     * @param ids
     */
    //delete from dish where id in (?, ?, ?)
    void deleteByIds(List<Long> ids);

    /**
     * 菜品起售、停售
     * @param dish
     *
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

 /**
  * 根据条件查询菜品数据
  * @param dish
  * @return
  */
    List<Dish> list(Dish dish);

    /**
     * 根据套餐id查询菜品
     * @param setmealId
     * @return
     */
    @Select("select d.* from dish d left join setmeal_dish sd on d.id = sd.dish_id where sd.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);
}
